/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package generadorva;

/**
 *
 * @author USUARIO
 */
public class LeapTime {

   private int[] lt = {2, 3, 4};
   private double[] p = {0.2, 0.5, 0.3};

   public int generate(double u) {
       int i = 0;
       int x = lt[i];
       double fx = p[i];
       while (u > fx) {
           i++;
           x = lt[i];
           fx += p[i];
       }
       return x;
   }
}
